﻿using System.Diagnostics;
using GalaSoft.MvvmLight.Messaging;
using Sfd.Entities;
using SfdClient.Messaging;

namespace SfdClient
{
    public class WpfListener : TraceListener
    {
        /// <summary>
        /// 
        /// When overridden in a derived class, writes the specified message to the listener you create in the derived class.
        /// </summary>
        /// <param name="message">A message to write. </param><filterpriority>2</filterpriority>
        public override void Write(string message)
        {
            Messenger.Default.Send(new AddLogMessage(message));
        }

        /// <summary>
        /// When overridden in a derived class, writes a message to the listener you create in the derived class, followed by a line terminator.
        /// </summary>
        /// <param name="message">A message to write. </param><filterpriority>2</filterpriority>
        public override void WriteLine(string message)
        {
            Messenger.Default.Send(new AddLogMessage(message));
        }

        public override void Write(string message, string category)
        {
            Messenger.Default.Send(new AddLogMessage(message, category));
        }

        public override void WriteLine(string message, string category)
        {
            Messenger.Default.Send(new AddLogMessage(message, category));
        }
    }
}
